package com.xianggu.designMode.combination.demo03;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author chengjy
 * @date 2025/3/20
 */
public class City implements PopulationNode{

    private String name;

    private List<PopulationNode> disttricts = new ArrayList<>();
    @Override
    public int counPopulation() {
        return disttricts.stream().mapToInt(PopulationNode::counPopulation).sum();
    }

    @Override
    public String getName() {
        return null;
    }

    public City(String name) {
        this.name = name;
    }

    public void addDistrict(District district){
        disttricts.add(district);
    }
    public void addDistricts(District... district){
        disttricts.addAll(Arrays.asList(district));
    }
}
